package com.tanhua.server.controller;

import com.tanhua.server.service.VoiceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.Map;

/**
 * 桃花传音功能
 */

@RestController
@Slf4j
@RequestMapping("/peachblossom")

// 还有缓存没做
public class PassingVoiceController {
    @Autowired
    private VoiceService voiceService;

    @PostMapping
    public ResponseEntity<Object> peachBlossom(MultipartFile soundFile) throws Exception {
//        System.out.println(soundFile);
        return voiceService.uploadVoice(soundFile);
    }

    @GetMapping
    public ResponseEntity<Object> findOne() throws ParseException {
        return voiceService.findOne();
    }
}
